package v1

import (
	"context"
	gpb "goTong/api/order/v1"
	"goTong/app/hlw/api/internal/data"
)

type OrderSrv interface {
	SubmitOrder(ctx context.Context, request *gpb.OrderRequest) error
}

type OrderService struct {
	data data.DataFactory
}

func (o OrderService) SubmitOrder(ctx context.Context, request *gpb.OrderRequest) error {
	_, err := o.data.Order().SubmitOrder(ctx, request)
	if err != nil {
		return err
	}
	return nil
}

// 这里不用sevice是为了防止循环引用，其实也可以把service放到同一个文件夹下，但是那样文件多了就分不清了  不好看
func NewOrder(data data.DataFactory) *OrderService {
	return &OrderService{data: data}
}

var _ OrderSrv = &OrderService{}
